﻿/*
 * KLF Headless Browser
 * Written by Kris Oye <kristianoye@gmail.com>
 * Copyright (C) 2011-2012.  All rights reserved.
 */
namespace KLF.Lib.Browser.DOM.HTML
{
    #region Using Statements

    using KLF.Lib.Browser.DOM.Interface;

    #endregion

    class HTMLLinkElement : HTMLElement, ILoadableContent
    {
        #region Constructors

        internal HTMLLinkElement(Document owner)
            : base(owner, "link")
        {
        }

        #endregion

        #region Attributes

        public bool HasLoaded { get; set; }

        public string RawCss { get; set; }

        #endregion

        #region DOM Level 2 HTML Compliance

        /// <summary>
        /// The character encoding of the resource being linked to.
        /// See the charset attribute definition in HTML 4.01.
        /// </summary>
        public string charset
        {
            get
            {
                return getAttribute(HTMLConstants.HTML_ATT_CHARSET);
            }
            set
            {
                setAttribute(HTMLConstants.HTML_ATT_CHARSET, value);
            }
        }

        /// <summary>
        /// Enables/disables the link. This is currently only used for style 
        /// sheet links, and may be used to activate or deactivate style sheets.
        /// </summary>
        public bool disabled { get; set; }

        /// <summary>
        /// The URI [IETF RFC 2396] of the linked resource. See the href attribute 
        /// definition in HTML 4.01.
        /// </summary>
        public string href
        {
            get
            {
                return getAttribute(HTMLConstants.HTML_ATT_HREF);
            }
            set
            {
                setAttribute(HTMLConstants.HTML_ATT_HREF, value);
            }
        }

        /// <summary>
        /// Language code of the linked resource. See the hreflang attribute 
        /// definition in HTML 4.01.
        /// </summary>
        public string hreflang
        {
            get
            {
                return getAttribute(HTMLConstants.HTML_ATT_HREFLANG);
            }
            set
            {
                setAttribute(HTMLConstants.HTML_ATT_HREFLANG, value);
            }
        }

        /// <summary>
        /// Designed for use with one or more target media. See the media 
        /// attribute definition in HTML 4.01.
        /// </summary>
        public string media
        {
            get
            {
                return getAttribute(HTMLConstants.HTML_ATT_MEDIA);
            }
            set
            {
                setAttribute(HTMLConstants.HTML_ATT_MEDIA, value);
            }
        }

        /// <summary>
        /// Forward link type. See the rel attribute definition in HTML 4.01.
        /// </summary>
        public string rel
        {
            get
            {
                return getAttribute(HTMLConstants.HTML_ATT_REL);
            }
            set
            {
                setAttribute(HTMLConstants.HTML_ATT_REL, value);
            }
        }

        /// <summary>
        /// Reverse link type. See the rev attribute definition in HTML 4.01.
        /// </summary>
        public string rev
        {
            get
            {
                return getAttribute(HTMLConstants.HTML_ATT_REV);
            }
            set
            {
                setAttribute(HTMLConstants.HTML_ATT_REV, value);
            }
        }

        /// <summary>
        /// Frame to render the resource in. See the target attribute 
        /// definition in HTML 4.01.
        /// </summary>
        public string target
        {
            get
            {
                return getAttribute(HTMLConstants.HTML_ATT_TARGET);
            }
            set
            {
                setAttribute(HTMLConstants.HTML_ATT_TARGET, value);
            }
        }

        /// <summary>
        /// Advisory content type. See the type attribute definition in 
        /// HTML 4.01.
        /// </summary>
        public string type
        {
            get
            {
                return getAttribute(HTMLConstants.HTML_ATT_TYPE);
            }
            set
            {
                setAttribute(HTMLConstants.HTML_ATT_TYPE, value);
            }
        }

        #endregion
    }
}
